#define _CRT_SECURE_NO_WARNINGS 1
////#include <iostream>
////using namespace std;
////
////const int N = 20;
////char q[N][N];
////bool col[N], dg[N], bdg[N];
////int n;
////
////void dfs(int r)
////{
////    if (r == n)
////    {
////        for (int i = 0; i < n; i++)
////            puts(q[i]);
////        puts("");
////        return;
////    }
////    for (int i = 0; i < n; i++)
////    {
////        if (!col[i] && !dg[r - i + n] && !bdg[i + r])
////        {
////            q[r][i] = 'Q';
////            col[i] = dg[r - i + n] = bdg[i + r] = true;
////            dfs(r + 1);
////            col[i] = dg[r - i + n] = bdg[i + r] = false;
////            q[r][i] = '.';
////        }
////    }
////}
////int main()
////{
////    scanf("%d", &n);
////    for (int i = 0; i < n; i++)
////        for (int j = 0; j < n; j++)
////            q[i][j] = '.';
////    dfs(0);
////    return 0;
////}
////#include <iostream>
////#include <cstdio>
////#include <cstring>
////
////using namespace std;
////typedef pair<int, int> PII;
////const int N = 105;
////int g[N][N], d[N][N];
////PII q[N * N];
////int n, m;
////int bfs()
////{
////    memset(d, -1, sizeof d);
////    int hh = 0, tt = -1;
////    d[0][0] = 0;
////    q[++tt] = { 0 ,0 };
////    int dx[4] = { -1, 0, 1, 0 }, dy[4] = { 0, 1, 0, -1 };
////    while (d[n - 1][m - 1] != -1)
////    {
////        int x, y;
////        auto t = q[++hh];
////        for (int i = 0; i < 4; i++)
////        {
////            x = t.first + dx[i], y = t.second + dy[i];
////            if (x < n && x >= 0 && y < m && y >= 0 && g[x][y] == 0)
////            {
////                q[++tt].first = x,
////                    q[tt].second = y;
////                d[x][y] = d[t.first][t.second] + 1;
////            }
////        }
////    }
////    return d[n - 1][m - 1];
////}
////int main()
////{
////    scanf("%d%d", &n, &m);
////    for (int i = 0; i < n; i++)
////        for (int j = 0; j < m; j++)
////            scanf("%d", &g[i][j]);
////    printf("%d", bfs());
////    return 0;
////}
//#include <iostream>
//#include <queue>
//#include <cstring>
//
//using namespace std;
//typedef pair<int, int> PII;
//const int N = 105;
//int g[N][N], d[N][N];
//queue<PII> q;
//int n, m;
//int bfs()
//{
//    memset(d, -1, sizeof d);
//    d[0][0] = 0;
//    q.push({ 0, 0 });
//    int dx[4] = { -1, 0, 1, 0 }, dy[4] = { 0, 1, 0, -1 };
//    while (d[n - 1][m - 1] == -1)
//    {
//        auto t = q.front();
//        q.pop();
//        int x, y;
//        for (int i = 0; i < 4; i++)
//        {
//            x = t.first + dx[i], y = t.second + dy[i];
//            if (x >= 0 && x < n && y >= 0 && y < m && d[x][y] == -1 && g[x][y] == 0)
//            {
//                q.push({ x, y });
//                d[x][y] = d[t.first][t.second] + 1;
//            }
//        }
//
//    }
//    return d[n - 1][m - 1];
//}
//int main()
//{
//    scanf("%d%d", &n, &m);
//    for (int i = 0; i < n; i++)
//        for (int j = 0; j < n; j++)
//            scanf("%d", &g[i][j]);
//    printf("%d", bfs());
//}
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
const int N = 1e5 + 10;
int n;
int h[N], e[N], ne[N], idx;
bool j[N];
int ans = N;
void add(int a, int b)
{
    e[idx] = b;
    ne[idx] = h[a];
    h[a] = idx++;
}
int dfs(int x)
{
    j[x] = true;
    int sum = 1, res = 0;
    for (int i = ne[x]; i != -1; i = ne[i])
    {
        if (!j[i])
        {
            int s = dfs(i);
            res = max(res, s);
            sum += s;
        }
    }
    res = max(res, n - sum);
    ans = min(res, ans);
    return sum;
}
int main()
{
    memset(h, -1, sizeof h);
    scanf("%d", &n);
    --n;
    while (n--)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        add(a, b);
    }
    dfs(1);
    printf("%d", ans);
    return 0;
}